<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<link href="${basePath}/css/plugins/jqgriddemo/css/ui.jqgrid-bootstrap.min.css" rel="stylesheet" />
<!-- zTreeStyle.css -->
<link rel="stylesheet" type="text/css" href="${basePath}/css/zTreeStyle/zTreeStyle/zTreeStyle.css">
<!doctype html>
<html>
<head>
</head>
<body class="gray-bg">
	<div class="creditbody">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;客户表>面见面签系统</span>
			<a href="javascript:void(0)"></a>
		</div>
		<div class="ibox-content ibox-zxsearchqu ">
			<div class="row">
				<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
					<div class="row">
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
							<input type="hidden" id="orgCode">
							<input type="text" placeholder="业务部门" id="orgName" name="orgName" onclick="orgName();" class="form-control smalliconcur smallicon">
						</div>
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
							<input type="text" placeholder="客户名" id="customerName" name="customerName" class="form-control">
						</div>
					</div>
				</div>
				<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4">
					<div class="row">
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
							<input type="text" placeholder="业务员" id="salesmanName" name="salesmanName" class="form-control">
						</div>
						<div class="col-xs-12 col-sm-12 col-md-12 col-lg-6">
							<select class="form-control" id="interviewStatus">
								<option value="200">面签成功</option>
								<option value="100">需要二次面签</option>
								<option value="9000">面签失败</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-12 col-sm-12 col-md-12 col-lg-4" id="buttonall">
					<button class="zhixcx" type="button" onclick="query();">执行查询</button>
				</div>
			</div>
		</div>

		<div class="ibox-content">
			<div class="jqGrid_wrapper">
				<table id="table_list_1"></table>
				<div id="pager_list_1"></div>
			</div>
		</div>
	</div>
	
	<div id="orgNameTree" style="display: none;">
		<div class="ibox-content" style="height: 480px;border: 1px solid #F5F5F6; overflow:auto;overflow-x: hidden;">
			<div id="treeDemo" class="ztree">&nbsp;</div>
		</div>
		<div class="ibox-content">
			<button class="btn dpbtn_green" type="button" onclick="confirm();">确定</button>
			<button class="btn dpbtn_red" type="button" onclick="cancel();">取消</button>
		</div>
	</div>
	
	<%@include file="/jsp/comm_js_include.jsp"%>
	<script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/jquery.jqGrid.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="${basePath}/js/plugins/jqgriddemo/js/grid.locale-cn.min.js"></script>
	<!--zTreeStyle.js-->
	<script type="text/javascript" src="${basePath}/js/zTreeStyle/jquery.ztree.core.js" charset="utf-8"></script>
	<script type="text/javascript" src="${basePath}/js/zTreeStyle/jquery.ztree.excheck.js" charset="utf-8"></script>
	<script src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
	<script type="text/javascript">
	jQuery(function($) {
		getData();
	});

    var getData = function() {
		var winWidth = $('div.ibox-content').width();
		var winHeight = document.body.offsetHeight - 310;
 	    $.jgrid.defaults.styleUI = 'Bootstrap';
	    jQuery("#table_list_1").jqGrid({
			url:'${basePath}/YwFaceToFaceSignController/multiList',
	        datatype : "json",
	        postData:{interviewStatus:$("#interviewStatus").val()},
	        colNames : [ '主键','业务提交时间','订单状态','','视频面签', '视频面签状态','客户姓名','身份证号码','实际贷款额','省公司', '业务部门', '业务员','经销商','车辆'],
	        colModel : [
					{name: 'replaceId', index: 'B.id', hidden:true},
					{name: 'submitTime',index: 'B.submitTime',width: 170,align: "center"},
					{name: 'busiStatusDisplay',index: 'B.busiStatus',width: 150,align: "center",formatter:function(a,b,c){
	               	 	return '<span class="ywstatus">' + a + '</span>';
	                }},
	                {name: 'busiStatus',index: 'E.busiStatus', hidden:true},
	                {name: 'interviewStatus',index: 'B.interviewStatus', hidden:true},
					{name: 'interviewStatusDisplay',index: 'B.interviewStatus',width: 180,align: "center"},
					{name: 'customerName',index: 'B.customerName',width: 130,align: "center"},
					{name: 'customerNo',index: 'B.customerName',width: 130,align: "center"},
					{name: 'realLoanAmount',index: 'B.realLoanAmount',width: 180,align: "center"},
					{name: 'fgsName',index: '',width: 180,align: "center"},
					{name: 'orgName',index: 'BO.orgName',width: 180,align: "center"},
					{name: 'salesmanName',index: 'S.name',width: 180,align: "center"},
					{name: 'dealerName',index: 'BDI.dealerName',width: 180,align: "center"},
					{name: 'carTypeDisplay',index: 'B.carType',width: 180,align: "center"}
					],
	          mtype : "post",
	          height: winHeight,
	          width:winWidth,  
	          shrinkToFit:false,
	          autoScroll: false,
	          rowNum: 15,
	          rowList: [15, 30, 45],
	          viewrecords: true,
	          pager: "#pager_list_1",
	          hidegrid: false,
	          multiselect : false,
	          altRows:true,
	          altclass:'someClass',
	          ondblClickRow:function(rowId,v,e)
	          {
	        	  var rowData = $("#table_list_1").jqGrid("getRowData", rowId);
	        	  var customerNo = rowData.customerNo;
	        	  var customerName = rowData.customerName;
	        	  layer.msg('正在进入，请稍后...',{icon: 16,shade: 0.01});
	        	  window.location.href="${basePath}/BaseCustomerViewController/customerDetail?customerNo=" + customerNo+"&customerName="+customerName;
	          },
	          jsonReader : {
	        	  root:"result.rows",
	        	  page: "result.page",
	        	  total: "result.total",
	        	  records: "result.records",
	        	  repeatitems: false,
	        	  id: "replaceId"
	          },
	          loadComplete:function(datas){
	        	  if (datas.flag == "100100") {
	                  layer.msg("查询成功!", {icon: 6, time: 1000});
	                  return;
	              }
	        	  if(datas.flag == '100802') {
					  top.location.href = thisLoginUrl;
					  return;
				  }
	
	        	  layer.msg(datas.message, {icon: 2});
	          },
	          gridComplete:function() {
	        	  var ids = $("#table_list_1").getDataIDs();
	        	  if(!ids || ids.length == 0) {
	        		  return;
	        	  }
	        	  for(var i = 0; i < ids.length; i++) {
	        		  var row = $("#table_list_1").getRowData(ids[i]);
	        		  var busiStatus = row.busiStatus;
	        		  if(busiStatus == 10) {
	        			  $('tr[id="' + ids[i] + '"] td span.ywstatus').addClass("dp-grid-green");
	        		  } else if(busiStatus == 30 || busiStatus == 40 || busiStatus == 50 || busiStatus == 70 || busiStatus == 80 || busiStatus == 85 || busiStatus == 90 || busiStatus == 100 || busiStatus == 110 || busiStatus == 200 || busiStatus == 210 || busiStatus == 250 || busiStatus == 390 || busiStatus == 400 || busiStatus == 450){
	        			  $('tr[id="' + ids[i] + '"] td span.ywstatus').addClass("dp-grid-blue");
	        		  } else if(busiStatus == 460 || busiStatus == 500) {
	        			  $('tr[id="' + ids[i] + '"] td span.ywstatus').addClass("dp-grid-yellow");
	        		  }else if(busiStatus == 9010 || busiStatus == 9020 || busiStatus == 9030 || busiStatus == 9040 || busiStatus == 9050 || busiStatus == 9060 || busiStatus == 9070 || busiStatus == 9080 || busiStatus == 9800 || busiStatus == 9810 || busiStatus == 9820 || busiStatus == 9830 || busiStatus == 9990 || busiStatus == 9999) {
	        			  $('tr[id="' + ids[i] + '"] td span.ywstatus').addClass("dp-grid-red");
	        		  }
	        	  }
	          }
	    });
    }

    window.onresize = function() {
    	$("#table_list_1").setGridWidth($(window).width()-80);
    }

    var query = function(){
    	var postData = $("#table_list_1").jqGrid("getGridParam", "postData");
    	var data = {};
    	data.unitCode = document.getElementById('orgCode').value || '';
    	data.customerName = document.getElementById('customerName').value || '';
    	data.salesmanName = document.getElementById('salesmanName').value || '';
    	data.interviewStatus = $("#interviewStatus").val();
    	$.extend(postData, data);
    	refresh();
    }
    
    var refresh = function() {
    	$("#table_list_1").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
    }
    
    
    var orgName = function(){
    	$.dpAjax({
    		url:'${basePath}/BaseBusiUnitController/list',
    		data:{'dpStatus':1},
   			success: function(datas){
   				
   				index = layer.open({
			    	  title:'业务单位列表',
			    	  type: 1,
			    	  area: ['600px', '600px'], //宽高
			    	  content: $("#orgNameTree")
			    });
		    				
			    var setting = {
					check: {
						enable: true
					},
					data: {
						simpleData: {
							enable: true
						}
					}
			     };	
   				
  				 var  arr = [];
  				 var result = datas.result.rows;
  				 for(var i=0;i<result.length;i++)
  				 {  
  					  var r = result[i];
  					  var objs = {};
  					  objs.id = r.replaceId;
  					  objs.pId = r.parentId;
  					  objs.orgCode=r.orgCode;
  					  objs.parentCode=r.parentCode;
  					  objs.name = r.orgName;
  					  arr.push(objs);
  					  if(r.replaceId == 1){
           		  	     objs.open = true;
   					  } else {
   						objs.open = false; 
   					  }
  				 }  
  				 zTrees_ = $.fn.zTree.init($("#treeDemo"), setting, arr);
   				 zTrees_.setting.check.chkboxType={"Y": "", "N": ""};
				 return;
   			}
    	});
    }
    
    var confirm = function(){
    	var zTree = $.fn.zTree.getZTreeObj("treeDemo"); 
	   	var nodes = zTree.getCheckedNodes(true);
	   	var id = nodes[0].id;
	   	if(id == 1)
	   	{
	   		layer.msg("无法选择顶级节点！", {icon: 5});
			return;
	   	}
	   	if(nodes.length == 0)
	   	{
	   		layer.msg("请选择业务单位！", {icon: 5});
			return;
	   	}
	   	if(nodes.length > 1)
	   	{
	   		layer.msg("请选择一个业务单位！", {icon: 5});
			return;
	   	}
	   	
	   	var orgCode = nodes[0].orgCode;
	   	var name = nodes[0].name;
	   	$("#orgCode").val(orgCode);
	   	$("#orgName").val(name);
	   	layer.close(index);
    }
</script>
</body>
</html>
